/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2018 All Rights Reserved.
 */
package com.antcloud.demo.antscheduler.nine1nine;

import java.util.List;
import java.util.concurrent.ThreadPoolExecutor;

import com.alipay.antschedulerclient.common.SplitChunkDataResult;
import com.alipay.antschedulerclient.handler.IClusterJobSplitHandler;
import com.alipay.antschedulerclient.model.ClusterJobSplitContext;
import com.alipay.antschedulerclient.model.chunk.ShardingChunkData;
import com.google.common.collect.Lists;

/**
 *
 * @author qian.lqlq
 * @version $Id: PaymentBalanceSpliter.java, v 0.1 2018年09月05日 18:38 qian.lqlq Exp $
 */
public class PaymentBalanceSpliter implements IClusterJobSplitHandler<ShardingChunkData> {

    @Override
    public SplitChunkDataResult<ShardingChunkData> handle(ClusterJobSplitContext context) {
        SplitChunkDataResult<ShardingChunkData> result = new SplitChunkDataResult<>();
        List<ShardingChunkData> dataList = Lists.newArrayList();
        for (BillItemTypeEnum type : BillItemTypeEnum.values()) {
            if (type != BillItemTypeEnum.BALANCE) {
                dataList.add(new ShardingChunkData(type.name()));
            }
        }
        result.setChunkDatum(dataList);
        result.setSuccess(true);
        return result;
    }

    @Override
    public String getName() {
        return "paymentBalanceSpliter";
    }

    @Override
    public ThreadPoolExecutor getThreadPool() {
        return null;
    }
}